package com.tentative.competition.web.controller.schedule.client;

import com.tentative.competition.common.annotation.Anonymous;
import com.tentative.competition.common.core.controller.BaseController;
import com.tentative.competition.common.core.domain.AjaxResult;
import com.tentative.competition.schedule.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther: Smile Huang
 * @date: 2023/6/25 21:22
 * @desc:
 * @version: 2.0
 */
@Api(tags = "client-首页")
@RestController
@RequestMapping("/client/home-page")
public class HomePageController extends BaseController {

    @Autowired
    private ScheduleAdminService scheduleAdminService;

    @Autowired
    private ScheduleBannerInfoService bannerInfoService;

    @Autowired
    private ScheduleNewsInfoService newsInfoService;

    @Autowired
    private ScheduleWorksService worksService;

    @Autowired
    private ScheduleOrgInfoService orgInfoService;

    @ApiOperation("获取赛程基础数据")
    @GetMapping(value = "/basics-info")
    @Anonymous
    public AjaxResult getBasicsInfo() {
        return success(scheduleAdminService.getBasicsInfo());
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "bannerType", value = "轮播类型", dataType = "String", dataTypeClass = String.class,required = true ),
            @ApiImplicitParam(name = "scheduleId", value = "赛程ID", dataType = "Long", dataTypeClass = Long.class,required = true ),
    })
    @ApiOperation("根据类型获取轮播信息")
    @GetMapping(value = "/banner-info")
    @Anonymous
    public AjaxResult getBannerInfoByType(@RequestParam(value = "bannerType") String bannerType,
                                          @RequestParam(value = "scheduleId") Long scheduleId) {
        return success(bannerInfoService.getBannerInfoByType(bannerType,scheduleId));
    }

    @ApiOperation("获取首页大赛动态")
    @GetMapping(value = "/dynamic/{scheduleId}")
    @Anonymous
    public AjaxResult getDynamicInfo(@PathVariable("scheduleId") Long scheduleId) {
        return success(newsInfoService.getDynamicInfo(scheduleId,false));
    }

    @ApiOperation("获取首页大赛简介")
    @GetMapping(value = "/intro/{scheduleId}")
    @Anonymous
    public AjaxResult getIntroInfo(@PathVariable("scheduleId") Long scheduleId) {
        return success(scheduleAdminService.getIntroInfo(scheduleId));
    }

    @ApiOperation("获取首页大赛时间")
    @GetMapping(value = "/time/{scheduleId}")
    @Anonymous
    public AjaxResult getScheduleTime(@PathVariable("scheduleId") Long scheduleId) {
        return success(scheduleAdminService.getInfo(scheduleId));
    }

    @ApiOperation("获取往届作品数据")
    @GetMapping(value = "/previous-works")
    @Anonymous
    public AjaxResult getPreviousWorks() {
        return success(worksService.getPreviousWorks());
    }

    @ApiOperation("获取组织机构数据")
    @GetMapping(value = "/org-info/{scheduleId}")
    @Anonymous
    public AjaxResult getOrgInfo(@PathVariable("scheduleId") Long scheduleId) {
        return success(orgInfoService.getPreviousWorks(scheduleId));
    }
}
